Added format specifier for yearqtr#7713
Added format specifier for yearqtr#7713LunaticSage218 wants to merge 8 commits intoRdatatable:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7713 +/- ##
==========================================
- Coverage 99.04% 99.04% -0.01%
==========================================
Files 87 87
Lines 17037 17138 +101
==========================================
+ Hits 16874 16974 +100
- Misses 163 164 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Benjamin Schwendinger <52290390+ben-schwen@users.noreply.github.com>
|
Solid first approach. Keep in mind that we strive for efficiency with |
| yearmon(x) | ||
| yearqtr(x) | ||
|
|
||
| yearqtr(x, format = c("numeric", "character")) |
There was a problem hiding this comment.
| yearqtr(x, format = c("numeric", "character")) | |
| yearqtr(x, format = c("numeric", "character")) | |
reinstate deletion of missing line
ben-schwen
left a comment
There was a problem hiding this comment.
We are close to being mergeable.
However, to fully close the issue you would also need to mirror the approach for yearmon with a similar encoding d="2019-01-01" as yearmon(d, "character") as "2019M1"
| \item{units}{one of the units listed for truncating. May be abbreviated.} | ||
| \item{ms}{ For \code{as.ITime} methods, what should be done with sub-second fractions of input? Valid values are \code{'truncate'} (floor), \code{'nearest'} (round), and \code{'ceil'} (ceiling). See Details. } | ||
| \item{format}{format is either \code{"numeric"} (default) or \code{"character"}. \code{"character"} formats the result as \code{"2025Q4"}.} | ||
| \item{format}{format is either \code{"numeric"} (default) or \code{"character"}. \code{"character"} formats the result as \code{"2025M4"} for \code{yearmon} and \code{"2025Q4"} for \code{yearqtr}.} |
There was a problem hiding this comment.
2025M04
Otherwise sorting character will be not as user expects, unless we go for format=factor where we can define order
There was a problem hiding this comment.
Maybe
ans[ok] = sprintf("%dM%02d", as.integer(yr), as.integer(mon))
so if a user sorts on the last two characters it's always integers?
There was a problem hiding this comment.
Maybe
ans[ok] = sprintf("%dM%02d", as.integer(yr), as.integer(mon))so if a user sorts on the last two characters it's always integers?
Yeah, thats exactly what I would do!
Towards #7694